﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;

namespace AUV5.DAL.Dao
{
    /// <summary>
    /// 功能：     WithDrawLog业务接口的实现
    /// 作者：     Wilson
    /// 日期：     2012/1/17
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class WithDrawLogSqlMapDao : BaseSqlMapDao, AUV5.DAL.Interface.IWithDrawLogDao
    {
        private static WithDrawLogSqlMapDao instance = new WithDrawLogSqlMapDao();

        private WithDrawLogSqlMapDao()
        {
            //
            // TODO: 此处添加WithDrawLogSqlMapDao的构造函数
            //
        }

        public static IWithDrawLogDao GetInstance()
        {
            return instance;
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                return (int)ExecuteQueryForObject("SelectWithDrawLogByMaxCounts", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<WithDrawLog> GetList()
        {
            try
            {
                return ExecuteQueryForList<WithDrawLog>("SelectWithDrawLog", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<WithDrawLog> GetListByParameters(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<WithDrawLog>("SelectWithDrawLogByParameters", objParameters);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="WithdrawLogID"></param>
        /// <returns></returns>
        public WithDrawLog GetDetail(System.String withdrawlogid)
        {
            try
            {
                return ExecuteQueryForObject<WithDrawLog>("SelectWithDrawLog", withdrawlogid) as WithDrawLog;
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="withdrawlog"></param>
        /// <returns></returns>
        public object Add(WithDrawLog withdrawlog)
        {
            //int id = GetId("WithDrawLog");
            //withdrawlog.WithdrawLogID = id;

            try
            {
                return ExecuteInsert("InsertWithDrawLog", withdrawlog);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="withdrawlog"></param>
        /// <returns></returns>
        public int Update(WithDrawLog withdrawlog)
        {
            try
            {
                return ExecuteUpdate("UpdateWithDrawLog", withdrawlog);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="WithdrawLogID"></param>
        /// <returns></returns>
        public int Delete(System.String withdrawlogid)
        {
            try
            {
                return ExecuteDelete("DeleteWithDrawLog", withdrawlogid);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="withdrawlog"></param>
        /// <returns></returns>
        public int Delete(WithDrawLog withdrawlog)
        {
            try
            {
                return ExecuteDelete("DeleteWithDrawLog", withdrawlog.WithdrawLogID);
            }
            catch
            {
                throw;
            }
        }

        #region##得到提现总额
        /// <summary>
        /// 得到提现总额
        /// 创建人：Wilson
        /// 创建时间：2012-1-17
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public decimal GetTotalAmountByUserId(object objParameters)
        {
            try
            {
                return Convert.ToDecimal(ExecuteQueryForObject("SelectTotalAmountByUserId", objParameters));
            }
            catch
            {
                throw;
            }
        }
        #endregion

        #region##通过UserId得到提现记录集合
        /// <summary>
        /// 通过UserId得到提现记录集合
        /// 创建人：Wilson
        /// 创建时间：2012-1-17     
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public IList<WithDrawLog> GetWithDrawListByUserId(string userId)
        {
            try
            {
                return ExecuteQueryForList<WithDrawLog>("SelectWithDrawListByUserId", userId);
            }
            catch
            {
                throw;
            }
        }
        #endregion
    }
}
